package com.example.controller;

import com.example.bean.WiselyMessage;
import com.example.bean.WiselyResponse;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class WsController {

    @MessageMapping("/welcome")
    @SendTo("/topic/getResponse")
    public WiselyResponse say(WiselyMessage wiselyMessage) throws InterruptedException {
        Thread.sleep(3000);
        return new WiselyResponse("welcome:" + wiselyMessage.getName() + "!");
    }

    @GetMapping("ws")
    public String ws() {
        return "ws";
    }

}
